package ModelLayer;


/**
 * This class registers data about a loan.
 * 
 * @author Sebastian K Munch
 * @version 08-11-2012
 */
public class Loan
{
    private DVD     dvd;
    private Copy    copy;
    private Person  person;
    private long    loanID;
    private int     status;
    private String  loanMadeDate;
    private String  toBeReturned;
    private String  returnedDate;
    
    public static final int     ACTIVE = 1,
                                RETURNED = 2;

    /**
     * Constructor for objects of class Loan
     */
    public Loan(DVD dvd, Copy copy, Person person, long loanID, String loanMadeDate, String toBeReturned)
    {
        this.dvd = dvd;
        this.copy = copy;
        this.person = person;
        this.loanID = loanID;
        this.loanMadeDate = loanMadeDate;
        this.toBeReturned = toBeReturned;
        status = ACTIVE;
        returnedDate = "";
    }
    
    /**
     * This method returs the dvd associatet with this loan.
     * 
     * @return  The dvd, as a DVD.
     */
    public DVD getDvd()
    {
        return dvd;
    }
    
    /**
     * This method returns the copy associated with this loan.
     * 
     * @return  The copy, as a Copy.
     */
    public Copy getCopy()
    {
        return copy;
    }
    
    /**
     * This method returns the person who made this loan.
     * 
     * @return  The person, as a Person.
     */
    public Person getPerson()
    {
        return person;
    }
    
    /**
     * This method returns the loan id associated with this loan.
     * 
     * @return  The id of this loan, as a long.
     */
    public long getLoanID()
    {
        return loanID;
    }
    
    /**
     * This method returns the status of the loan.
     * 
     * @return  The statust of the loan. An int.
     */
    public int getStatus()
    {
        return status;
    }
    
    /**
     * Returns the date on withc this loan was made.
     * 
     * @return  The made date, as a String.
     */
    public String getLoanMadeDate()
    {
        return loanMadeDate;
    }
    
    /**
     * The date on witch this loan is to be returned.
     * 
     * @return  The return date of this loan, as a String.
     */
    public String getToBeReturned()
    {
        return toBeReturned;
    }
    
    /**
     * This method return the date on witch this loan was returned.
     * 
     * @return  The returned date of this loan.
     */
    public String getReturned()
    {
        return returnedDate;
    }
    
    /**
     * This method returns a text describing the status of this loaan.
     * 
     * @return  A desciption of the loan status, as a string.
     */
    public String getStatusText()
    {
        String text;
        switch(status)
        {
            case ACTIVE:
                text = "Active";
                break;
            case RETURNED:
                text = "Returned";
                break;
            default:
                text = "NA";
                break;
        }
        return text;
    }
    
    /**
     * This method changes the dvd that is associated with this loan.
     * 
     * @param   dvd   The new dvd. A DVD.
     */
    public void setDvd(DVD dvd)
    {
        this.dvd = dvd;
    }
    
    /**
     * This method changes the copy that is associated with this loan.
     * 
     * @param   copy    The new copy. A Copy.
     */
    public void setCcpy(Copy copy)
    {
        this.copy = copy;
    }
    
    /**
     * This method changes the person associated with this loan.
     * 
     * @param   person    The new person associated with this method. A Person.
     */
    public void setPerson(Person person)
    {
        this.person = person;
    }
    
    /**
     * This method changes the loan id associated with this loan.
     * 
     * @param   loanID  The new loan id. A long.
     */
    public void setLoanID(long loanID)
    {
        this.loanID = loanID;
    }
    
    /**
     * This method changes the status of the loan.
     * 
     * @param   status  The new status of the loan. an int.
     */
    public void setStatus(int status)
    {
        this.status = status;
    }
    
    /**
     * This method chanes the date on witch the loan is to be returned.
     * 
     * @param   toBeReturned    The new date. A String.
     */
    public void setToBeReturned(String toBeReturned)
    {
        this.toBeReturned = toBeReturned;
    }
    
    /**
     * This method changes the date on wich the loan was returned.
     */
    public void setReturned(String returned)
    {
        returnedDate = returned;
    }
}
